package com.example.gallery;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Environment;
import android.util.Log;

public class DBHelper extends SQLiteOpenHelper {
	private static final String TAG = "DBHelper";
	private static final String DB_NAME =  Environment.getExternalStorageDirectory().getAbsolutePath() + "/data/gallery_board.db";
//	private static final String DB_NAME =  "board.db";
	private static final int DB_VERSION = 1;
	
//	게시글 저장
	private static final String TB_BOARD = "CREATE TABLE BOARD"
										+ "			(NO INTEGER PRIMARY KEY AUTOINCREMENT," + "TITLE TEXT, "
													+ "CONTENT TEXT , " + "BOARD_DATE TEXT , " + "ID TEXT );";
//	회원정보 저장
	private static final String TB_MEMBER = "CREATE TABLE MEMBER" +
												"(ID TEXT PRIMARY KEY," +
												"PW TEXT," +
												"REG_DATE TEXT);";
	
//	이미지 저장 테이블
	private static final String TB_IMAGE = "CREATE TABLE IMAGE " +
			"													(NO INTEGER PRIMARY KEY AUTOINCREMENT, " +
			"													 ID TEXT," +
			"													BOARD_NO INTEGER ," +
			"													NAME TEXT);";
	
	public DBHelper(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		 db.execSQL(TB_BOARD);
		 db.execSQL(TB_MEMBER);
		 db.execSQL(TB_IMAGE);
		 Log.i(TAG, "TABLE ��Ϸ�");
	}

	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		String sql = "DROP TABLE IF EXISTS BOARD";
		db.execSQL(sql);
		onCreate(db);
	}

}
